<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGoodsAttributeAccessTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create ('goods_attribute_access', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->uuid ('id')->primary ('id');//uuid主键
            $table->uuid ('goods_id');//商品ID
            $table->uuid ('attribute_id');//属性名ID
            $table->uuid ('attribute_value_id');//属性值ID
            $table->foreign ('attribute_id')->references ('id')->on ('goods_attribute')->onDelete ('cascade');//属性名外键
            $table->foreign ('attribute_value_id')->references ('id')->on ('goods_attribute_value')->onDelete ('cascade');//属性值外键
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists ('goods_attribute_access');
    }
}
